package com.gt.provider;

import com.alibaba.dubbo.config.annotation.Service;
import com.gt.model.User;
import com.gt.service.DemoService;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Service(protocol="dubbo-jvm",registry="test2")
public class DemoServiceImpl implements DemoService {
    @Override
    public Integer add(Integer a, Integer b) {
        System.out.println("add 被调用a="+a+",b="+b);
        return a+b;
    }

    @Override
    public List<Object> toList(Object... args) {
        List<Object> list = new ArrayList<>();
        Collections.addAll(list, args);
        System.out.println("toList 接口被调用，返回数据="+ list);
        return list;
    }

    @Override
    public User getUser(User user) {
        System.out.println("User 接口被调用，"+user.toString());
        return user;
    }

    @Override
    public void throwsThroeable() {
        try {
            throw new Exception("抛出测试异常");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
